import java.util.*;
// 注意类名必须为 Main, 不要有任何 package xxx 信息
public class test {
    // 牛客 打怪
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int t = in.nextInt();
        while(t-- > 0){
            int h = in.nextInt();
            int a = in.nextInt();
            int H = in.nextInt();
            int A = in.nextInt();
            int key = H / a;
            if(H % a != 0){
                key++;
            }
            int cub = (key - 1) * A;
            if(cub == 0){
                System.out.println(-1);
                continue;
            }
            int sum = ((h % cub == 0 ? (h / cub) - 1 : h / cub));
            System.out.println(sum);
        }
    }
    // 牛客 字符串的分类
    public static int n;
    public static HashMap<Character, Integer>[] map;
    public static void main1(String[] args) {
        Scanner in = new Scanner(System.in);
        n = in.nextInt();
        String[] ss = new String[n];
        ArrayList<String>[] list = new ArrayList[n];
        map = new HashMap[n];
        for (int i = 0; i < n; i++) {
            map[i] = new HashMap<>();
            list[i] = new ArrayList<>();
        }
        for (int i = 0; i < n; i++) {
            String s = in.next();
            ss[i] = s;
            for (int j = 0; j < s.length(); j++) {
                char c = s.charAt(j);
                map[i].put(c, map[i].getOrDefault(c, 0) + 1);
            }
        }
        boolean[] count = new boolean[n];
        for (int i = 0; i < n; i++) {
            if(count[i]) continue;
            count[i] = true;
            HashMap<Character, Integer> m1 = new HashMap<>(map[i]);
            for (int j = i + 1; j < n; j++) {
                if (count[j]) continue;
                HashMap<Character, Integer> m2 = new HashMap<>(map[j]);
                boolean flg = false;
                for (char k = 'a' - 'a' ; k <= 'z' + 'z'; k++) {
                    if (m1.getOrDefault(k, 0) != m2.getOrDefault(k, 0)) {
                        flg = true;
                        break;
                    }
                }
                if (!flg) {
                    list[i].add(ss[j]);
                    count[j] = true;
                }
            }
            if(list[i].size() == 0){
                list[i].add(ss[i]);
            }
        }
        int sum = 0;
        for (int i = 0; i < n; i++) {
            if (list[i].size() > 0) {
                sum++;
            }
        }
        System.out.println(sum);
    }
    // 牛客 城市群数量
    public static ArrayList<Integer>[] list;
    public static int citys (ArrayList<ArrayList<Integer>> m) {
        int n1 = m.size();
        int n2 = m.get(0).size();
        int[][] nums = new int[n1][n2];
        for (int i = 0; i < n1; i++) {
            for (int j = 0; j < n2; j++) {
                nums[i][j] = m.get(i).get(j);
            }
        }
        list = new ArrayList[n1];
        for (int i = 0; i < n1; i++) {
            list[i] = new ArrayList<>();
        }
        for (int i = 0; i < n1; i++) {
            for (int j = 0; j < n2; j++) {
                if (nums[i][j] == 1) {
                    list[i].add(j);
                    list[j].add(i);
                }
            }
        }
        int sum = 0;
        boolean[] count = new boolean[n1];
        for (int i = 0; i < n1; i++) {
            if(count[i]) continue;
            Queue<Integer> q = new LinkedList<>();
            q.add(i);
            while(!q.isEmpty()){
                int a = q.poll();
                if(count[a]) continue;
                count[a] = true;
                for(int b:list[a]){
                    if(count[b]) continue;
                    q.add(b);
                }
            }
            sum++;
        }
        return sum;
    }
}